﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;

namespace Raider.WinForms.Actions.Linkage
{
    /// <summary>
    /// Base class for action linkage attributes.
    /// </summary>
    public abstract class LinkAttribute : Attribute
    {
        protected LinkAttribute(params Type[] clientTypes)
        {
            ClientTypes = new ReadOnlyCollection<Type>(clientTypes);
        }

        /// <summary>
        /// Types of the client components.
        /// </summary>
        public ReadOnlyCollection<Type> ClientTypes
        {
            get;
            private set;
        }

        /// <summary>
        /// Factory method, which creates the ActionLinker object to link
        /// specified member of the action with the client components.
        /// </summary>
        /// <param name="actionMember">Member marked with the current attribute.</param>
        public abstract ActionMemberLinker CreateLinker(MemberInfo actionMember);
    }
}
